<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" /> 
    <title> - 天地维杰网</title>
    <meta name="keywords" content="系统架构,shutdown,不与天斗,Domino,博客,程序员,架构师,笔记,技术,分享,java,Redis">
    
    <meta property="og:title" content="">
    <meta property="og:site_name" content="天地维杰网">
    <meta property="og:image" content="/img/author.jpg"> 
    <meta name="title" content=" - 天地维杰网" />
    <meta name="description" content="天地维杰网 | 博客 | 软件 | 架构 | Java "> 
    <link rel="shortcut icon" href="http://www.shutdown.cn/img/favicon.ico" />
    <link rel="apple-touch-icon" href="http://www.shutdown.cn/img/apple-touch-icon.png" />
    <link rel="apple-touch-icon-precomposed" href="http://www.shutdown.cn/img/apple-touch-icon.png" />
    <link href="http://www.shutdown.cn/js/vendor/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />
    <link href="http://www.shutdown.cn/js/vendor/fancybox/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />
    <link href="http://www.shutdown.cn/css/main.css" rel="stylesheet" type="text/css" />
    <link href="http://www.shutdown.cn/css/syntax.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Pisces',
    sidebar: {"position":"left","display":"post"},
     fancybox: true, 
    motion: true
  };
</script>
</head>
<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">
<div class="container one-collumn sidebar-position-left page-home  ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"> <div class="site-meta  custom-logo ">

  <div class="custom-logo-site-title">
    <a href="http://www.shutdown.cn"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">天地维杰网</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">人如秋鸿来有信，事若春梦了无痕</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>

<nav class="site-nav">
    <ul id="menu" class="menu">
      
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />首页
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/redis/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-battery-full"></i> <br />Redis
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/java/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-coffee"></i> <br />java
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/linux/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-linux"></i> <br />linux
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/daily/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-bug"></i> <br />日常问题
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/spring/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-child"></i> <br />Spring和Springboot
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/spring/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-fire"></i> <br />Mac相关
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/middleware/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-gavel"></i> <br />中间件
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/jiagou/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-rocket"></i> <br />架构
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/python/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-ship"></i> <br />python
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/front/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-bolt"></i> <br />前端
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/categories/jvm/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-balance-scale"></i> <br />JVM
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/post/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />归档
          </a>
        </li>
      
        <li class="menu-item ">
          <a href="http://www.shutdown.cn/about/" rel="section">
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />关于
          </a>
        </li>
      
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger"> <i class="menu-item-icon fa fa-search fa-fw"></i> <br /> 搜索</a>
      </li>
    </ul>
    <div class="site-search">
      <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>

    </div>
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
<section id="posts" class="posts-expand">
  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">
    <header class="post-header">
      <h1 class="post-title" itemprop="name headline">
        <a class="post-title-link" href="http://www.shutdown.cn/post/cachecloud%E6%85%A2%E6%97%A5%E5%BF%97%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1%E5%88%9B%E5%BB%BA%E6%B5%81%E7%A8%8B%E5%88%86%E6%9E%90/" itemprop="url">
        
        </a>
      </h1>
      <div class="post-meta">
      <span class="post-time">
<span class="post-meta-item-icon">
    <i class="fa fa-calendar-o"></i>
</span>
<span class="post-meta-item-text">时间：</span>
<time itemprop="dateCreated" datetime="2016-03-22T13:04:35+08:00" content="0001-01-01">
    0001-01-01
</time>
</span> 
      
      
       <span>
&nbsp; | &nbsp;
<span class="post-meta-item-icon">
    <i class="fa fa-eye"></i>
</span>
<span class="post-meta-item-text">阅读：</span>
<span class="leancloud-visitors-count">513 字 ~3分钟</span>
</span>
      </div>
    </header>
    <div class="post-body" itemprop="articleBody">
    

    <p>CACHECLOUD慢日志定时任务创建流程分析</p>

<p>spring-load.xml中的配置</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#8f5902;font-style:italic">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span style="color:#204a87;font-weight:bold">&lt;beans</span> <span style="color:#c4a000">xmlns=</span><span style="color:#4e9a06">&#34;http://www.springframework.org/schema/beans&#34;</span>
       <span style="color:#c4a000">xmlns:xsi=</span><span style="color:#4e9a06">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
       <span style="color:#c4a000">xsi:schemaLocation=</span><span style="color:#4e9a06">&#34;http://www.springframework.org/schema/beans
</span><span style="color:#4e9a06">        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
</span><span style="color:#4e9a06">        &#34;</span> <span style="color:#c4a000">default-autowire=</span><span style="color:#4e9a06">&#34;byName&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>

    <span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic">初始化加载已有实例，测试时禁用</span><span style="color:#8f5902;font-style:italic">--&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;bean</span> <span style="color:#c4a000">class=</span><span style="color:#4e9a06">&#34;com.gome.cache.init.RedisInitLoad&#34;</span> <span style="color:#c4a000">init-method=</span><span style="color:#4e9a06">&#34;init&#34;</span> <span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;bean</span> <span style="color:#c4a000">class=</span><span style="color:#4e9a06">&#34;com.gome.cache.init.MachineInitLoad&#34;</span> <span style="color:#c4a000">init-method=</span><span style="color:#4e9a06">&#34;init&#34;</span> <span style="color:#204a87;font-weight:bold">/&gt;</span>
<span style="color:#204a87;font-weight:bold">&lt;/beans&gt;</span></code></pre></div>
<p>在spring-local.xml中是没有引入这个配置的，测试时禁用了，在这个配置中增加这个引用即和线上一样</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#8f5902;font-style:italic">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span style="color:#204a87;font-weight:bold">&lt;beans</span> <span style="color:#c4a000">xmlns=</span><span style="color:#4e9a06">&#34;http://www.springframework.org/schema/beans&#34;</span>
       <span style="color:#c4a000">xmlns:xsi=</span><span style="color:#4e9a06">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
       <span style="color:#c4a000">xsi:schemaLocation=</span><span style="color:#4e9a06">&#34;http://www.springframework.org/schema/beans
</span><span style="color:#4e9a06">        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-config.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-quartz.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
  	<span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic"> 增加 spring</span><span style="color:#8f5902;font-style:italic">-</span><span style="color:#8f5902;font-style:italic">load.xml的配置</span><span style="color:#8f5902;font-style:italic">--&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-load.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-mybatis.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-service.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-data.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-manage.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-mvc.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-jmx.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-alert.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-client-report.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-inspector.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-gcache.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-monitor.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;import</span> <span style="color:#c4a000">resource=</span><span style="color:#4e9a06">&#34;classpath:spring/spring-gmq.xml&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
<span style="color:#204a87;font-weight:bold">&lt;/beans&gt;</span></code></pre></div>
<p>启动后会调用  RedisInitLoad类的init方法，debug判断要去掉，否则无法进入部署慢日志收集任务方法</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#204a87;font-weight:bold">public</span> <span style="color:#204a87;font-weight:bold">void</span> <span style="color:#000">init</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">IS_DEBUG</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
            <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">warn</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#34;isDebug=true return&#34;</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">return</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span>
        <span style="color:#a40000">…</span><span style="color:#a40000">…</span><span style="color:#000">省略</span><span style="color:#a40000">…</span><span style="color:#a40000">…</span></code></pre></div>
<p>RedisInitLoad类的init方法中调用initByType方法创建慢日志收集的触发器。</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java"><span style="color:#204a87;font-weight:bold">private</span> <span style="color:#204a87;font-weight:bold">void</span> <span style="color:#000">initByType</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">int</span> <span style="color:#000">type</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        <span style="color:#000">List</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">InstanceInfo</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">instanceInfoList</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceDao</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getInstListByType</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">type</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#204a87;font-weight:bold">for</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">InstanceInfo</span> <span style="color:#000">instanceInfo</span> <span style="color:#ce5c00;font-weight:bold">:</span> <span style="color:#000">instanceInfoList</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                    <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getPort</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">TypeUtil</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isRedisSentinel</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getType</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                <span style="color:#204a87;font-weight:bold">continue</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#ce5c00;font-weight:bold">}</span>
            <span style="color:#000">String</span> <span style="color:#000">host</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getIp</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">int</span> <span style="color:#000">port</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getPort</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#000">Long</span> <span style="color:#000">appId</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getAppId</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#000">redisCenter</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">deployRedisCollection</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
          	<span style="color:#8f5902;font-style:italic">//这里给每个实例增加慢日志收集的job
</span><span style="color:#8f5902;font-style:italic"></span>            <span style="color:#000">redisCenter</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">deployRedisSlowLogCollection</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span>
        <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">info</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#34;init redis type={} deploy instance done.&#34;</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">type</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
    <span style="color:#ce5c00;font-weight:bold">}</span></code></pre></div>
<p>RedisCenterImpl的deployRedisSlowLogCollection方法部署定时任务</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java">    <span style="color:#5c35cc;font-weight:bold">@Override</span>
    <span style="color:#204a87;font-weight:bold">public</span> <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">deployRedisSlowLogCollection</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">long</span> <span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">String</span> <span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">int</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        <span style="color:#000">Assert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isTrue</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">appId</span> <span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">0</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">Assert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">hasText</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">Assert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isTrue</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">port</span> <span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">0</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">Map</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">String</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">Object</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">dataMap</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#204a87;font-weight:bold">new</span> <span style="color:#000">HashMap</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">String</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">Object</span><span style="color:#ce5c00;font-weight:bold">&gt;</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">put</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">HOST_KEY</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">put</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">PORT_KEY</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">put</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">APP_KEY</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">JobKey</span> <span style="color:#000">jobKey</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">JobKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">jobKey</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">REDIS_SLOWLOG_JOB_NAME</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">REDIS_SLOWLOG_JOB_GROUP</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">TriggerKey</span> <span style="color:#000">triggerKey</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">TriggerKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">ObjectConvert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">linkIpAndPort</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">ConstUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">REDIS_SLOWLOG_TRIGGER_GROUP</span> <span style="color:#ce5c00;font-weight:bold">+</span> <span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">result</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">schedulerCenter</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">deployJobByCron</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">jobKey</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">ScheduleUtil</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getRandomHourCron</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">false</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#000">result</span><span style="color:#ce5c00;font-weight:bold">;</span>
    <span style="color:#ce5c00;font-weight:bold">}</span></code></pre></div>
<p>SchedulerCenter的实现类SchedulerCenterImpl中，注入了 clusterScheduler，这个bean是在spring-quartz.xml中定义的</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml">    <span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic"> 分布式QuartzScheduler </span><span style="color:#8f5902;font-style:italic">--&gt;</span>
    <span style="color:#204a87;font-weight:bold">&lt;bean</span> <span style="color:#c4a000">id=</span><span style="color:#4e9a06">&#34;clusterScheduler&#34;</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;clusterScheduler&#34;</span> <span style="color:#c4a000">lazy-init=</span><span style="color:#4e9a06">&#34;false&#34;</span> <span style="color:#c4a000">class=</span><span style="color:#4e9a06">&#34;org.springframework.scheduling.quartz.SchedulerFactoryBean&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;dataSource&#34;</span> <span style="color:#c4a000">ref=</span><span style="color:#4e9a06">&#34;cacheCloudDB&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span><span style="color:#204a87;font-weight:bold">&lt;/property&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;taskExecutor&#34;</span> <span style="color:#c4a000">ref=</span><span style="color:#4e9a06">&#34;quartzThreadPool&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic">
</span><span style="color:#8f5902;font-style:italic">        &lt;property name=&#34;transactionManager&#34; ref=&#34;transactionManager&#34;/&gt;
</span><span style="color:#8f5902;font-style:italic">        </span><span style="color:#8f5902;font-style:italic">--&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;quartzProperties&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>
            <span style="color:#204a87;font-weight:bold">&lt;props</span><span style="color:#204a87;font-weight:bold">&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.scheduler.instanceName&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>CacheCloudScheduler<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.scheduler.instanceId&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>AUTO<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.class&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>org.quartz.impl.jdbcjobstore.JobStoreTX<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.driverDelegateClass&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>org.quartz.impl.jdbcjobstore.StdJDBCDelegate<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic"> 表名前缀 </span><span style="color:#8f5902;font-style:italic">--&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.tablePrefix&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>QRTZ_<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.isClustered&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>${isClustered}<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.clusterCheckinInterval&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>15000<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.maxMisfiresToHandleAtATime&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>120<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.jobStore.misfireThreshold&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>60000<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic"> 打开JMX 配置 </span><span style="color:#8f5902;font-style:italic">--&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.scheduler.jmx.export&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>true<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.plugin.shutdownHook.class&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>org.quartz.plugins.management.ShutdownHookPlugin<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.quartz.plugin.shutdownHook.cleanShutdown&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>true<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;prop</span> <span style="color:#c4a000">key=</span><span style="color:#4e9a06">&#34;org.terracotta.quartz.skipUpdateCheck&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>true<span style="color:#204a87;font-weight:bold">&lt;/prop&gt;</span>
                <span style="color:#8f5902;font-style:italic">&lt;!--</span><span style="color:#8f5902;font-style:italic">&lt;prop key=&#34;org.quartz.plugin.triggHistory.class&#34;&gt;org.quartz.plugins.history.LoggingJobHistoryPlugin&lt;/prop&gt;</span><span style="color:#8f5902;font-style:italic">--&gt;</span>

            <span style="color:#204a87;font-weight:bold">&lt;/props&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;/property&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;schedulerName&#34;</span> <span style="color:#c4a000">value=</span><span style="color:#4e9a06">&#34;CacheCloudScheduler&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;applicationContextSchedulerContextKey&#34;</span> <span style="color:#c4a000">value=</span><span style="color:#4e9a06">&#34;applicationContext&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;overwriteExistingJobs&#34;</span> <span style="color:#c4a000">value=</span><span style="color:#4e9a06">&#34;true&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;waitForJobsToCompleteOnShutdown&#34;</span> <span style="color:#c4a000">value=</span><span style="color:#4e9a06">&#34;false&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;startupDelay&#34;</span> <span style="color:#c4a000">value=</span><span style="color:#4e9a06">&#34;10&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;autoStartup&#34;</span> <span style="color:#c4a000">value=</span><span style="color:#4e9a06">&#34;true&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;triggers&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>
            <span style="color:#204a87;font-weight:bold">&lt;array</span><span style="color:#204a87;font-weight:bold">&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;cleanUpStatisticsTrigger&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;hostInspectorTrigger&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;appInspectorTrigger&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;appDailyTrigger&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
            <span style="color:#204a87;font-weight:bold">&lt;/array&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;/property&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;property</span> <span style="color:#c4a000">name=</span><span style="color:#4e9a06">&#34;jobDetails&#34;</span><span style="color:#204a87;font-weight:bold">&gt;</span>
            <span style="color:#204a87;font-weight:bold">&lt;array</span><span style="color:#204a87;font-weight:bold">&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;redisJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;machineJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;serverJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;machineMonitorJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;redisSlowLogJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;cleanUpStatisticsJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;inspectorJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
                <span style="color:#204a87;font-weight:bold">&lt;ref</span> <span style="color:#c4a000">bean=</span><span style="color:#4e9a06">&#34;appDailyJobDetail&#34;</span><span style="color:#204a87;font-weight:bold">/&gt;</span>
            <span style="color:#204a87;font-weight:bold">&lt;/array&gt;</span>
        <span style="color:#204a87;font-weight:bold">&lt;/property&gt;</span>

    <span style="color:#204a87;font-weight:bold">&lt;/bean&gt;</span></code></pre></div>
<p>部署定时任务</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java">    <span style="color:#5c35cc;font-weight:bold">@Override</span>
    <span style="color:#204a87;font-weight:bold">public</span> <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">deployJobByCron</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">JobKey</span> <span style="color:#000">jobKey</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">TriggerKey</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">Map</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">String</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">Object</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">String</span> <span style="color:#000">cron</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">replace</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        <span style="color:#000">Assert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isTrue</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">jobKey</span> <span style="color:#ce5c00;font-weight:bold">!</span><span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#204a87;font-weight:bold">null</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">Assert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isTrue</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">triggerKey</span> <span style="color:#ce5c00;font-weight:bold">!</span><span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#204a87;font-weight:bold">null</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#000">Assert</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isTrue</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">CronExpression</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isValidExpression</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">cron</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#4e9a06">&#34;invalid cron = &#34;</span> <span style="color:#ce5c00;font-weight:bold">+</span> <span style="color:#000">cron</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#204a87;font-weight:bold">try</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        		<span style="color:#8f5902;font-style:italic">//获取相应的任务执行器
</span><span style="color:#8f5902;font-style:italic"></span>            <span style="color:#000">JobDetail</span> <span style="color:#000">jobDetail</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">clusterScheduler</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getJobDetail</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">jobKey</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">jobDetail</span> <span style="color:#ce5c00;font-weight:bold">=</span><span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#204a87;font-weight:bold">null</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">error</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#34;JobKey {}:{} is not exist&#34;</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">jobKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getName</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">jobKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getGroup</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
                <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#204a87;font-weight:bold">false</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#ce5c00;font-weight:bold">}</span>
            <span style="color:#8f5902;font-style:italic">//在这里创建定时触发任务
</span><span style="color:#8f5902;font-style:italic"></span>            <span style="color:#000">fireCronTrigger</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">jobDetail</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">cron</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">replace</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span> <span style="color:#204a87;font-weight:bold">catch</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">Exception</span> <span style="color:#000">e</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
            <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">error</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">e</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getMessage</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">e</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#204a87;font-weight:bold">false</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span>

        <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#204a87;font-weight:bold">true</span><span style="color:#ce5c00;font-weight:bold">;</span>
    <span style="color:#ce5c00;font-weight:bold">}</span></code></pre></div>
<p>激活触发器</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java">    <span style="color:#204a87;font-weight:bold">private</span> <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">fireCronTrigger</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">TriggerKey</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">JobDetail</span> <span style="color:#000">jobDetail</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">String</span> <span style="color:#000">cron</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">replace</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">Map</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">String</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">Object</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        <span style="color:#204a87;font-weight:bold">try</span> <span style="color:#ce5c00;font-weight:bold">{</span>
            <span style="color:#204a87;font-weight:bold">boolean</span> <span style="color:#000">isExists</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">clusterScheduler</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">checkExists</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">isExists</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">replace</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                    <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">warn</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#34;replace trigger={}:{} &#34;</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getName</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getGroup</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
                    <span style="color:#000">clusterScheduler</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">unscheduleJob</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
                <span style="color:#ce5c00;font-weight:bold">}</span> <span style="color:#204a87;font-weight:bold">else</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                    <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">info</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#34;exist trigger={}:{} &#34;</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getName</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getGroup</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
                    <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#204a87;font-weight:bold">false</span><span style="color:#ce5c00;font-weight:bold">;</span>
                <span style="color:#ce5c00;font-weight:bold">}</span>
            <span style="color:#ce5c00;font-weight:bold">}</span>
            <span style="color:#000">Date</span> <span style="color:#000">startDate</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">DateUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">addSeconds</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">new</span> <span style="color:#000">Date</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">20</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
          	<span style="color:#8f5902;font-style:italic">//组建定时任务触发器
</span><span style="color:#8f5902;font-style:italic"></span>            <span style="color:#000">Trigger</span> <span style="color:#000">trigger</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">TriggerBuilder</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">newTrigger</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span>
                    <span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">withIdentity</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">triggerKey</span><span style="color:#ce5c00;font-weight:bold">)</span>
                    <span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">forJob</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">jobDetail</span><span style="color:#ce5c00;font-weight:bold">)</span>
                    <span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">withSchedule</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">CronScheduleBuilder</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">cronSchedule</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">cron</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span>
                    <span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">startAt</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">startDate</span><span style="color:#ce5c00;font-weight:bold">)</span>
                    <span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">build</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">dataMap</span> <span style="color:#ce5c00;font-weight:bold">!</span><span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#204a87;font-weight:bold">null</span> <span style="color:#ce5c00;font-weight:bold">&amp;</span><span style="color:#ce5c00;font-weight:bold">&amp;</span> <span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">size</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">0</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                <span style="color:#000">trigger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getJobDataMap</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">putAll</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">dataMap</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#ce5c00;font-weight:bold">}</span>
            <span style="color:#000">clusterScheduler</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">scheduleJob</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">trigger</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span> <span style="color:#204a87;font-weight:bold">catch</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">SchedulerException</span> <span style="color:#000">e</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
            <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">error</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">e</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getMessage</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">e</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#204a87;font-weight:bold">false</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span>
        <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#204a87;font-weight:bold">true</span><span style="color:#ce5c00;font-weight:bold">;</span>
    <span style="color:#ce5c00;font-weight:bold">}</span></code></pre></div>
<p>这里看的触发器的时间是每个小时的随机某分钟某秒，直接从实例服务器获取最新100条慢日志</p>

<div  align="center"><img src="https://wejack639.oss-cn-beijing.aliyuncs.com/blogimages/img/20211103181405.png" width = 900 /> </div>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java">        <span style="color:#8f5902;font-style:italic">// 从redis中获取慢查询日志，直接从服务器获取最新100条慢日志
</span><span style="color:#8f5902;font-style:italic"></span>        <span style="color:#000">List</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">RedisSlowLog</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">redisLowLogList</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">getRedisSlowLogs</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">100</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">CollectionUtils</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isEmpty</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">redisLowLogList</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
            <span style="color:#204a87;font-weight:bold">return</span> <span style="color:#000">Collections</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">emptyList</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span></code></pre></div>
<p>如果要去除自定的慢日志的job，可以将RedisInitLoad类的相应代码注释掉。</p>
<div class="highlight"><pre style="background-color:#f8f8f8;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-java" data-lang="java">		<span style="color:#204a87;font-weight:bold">private</span> <span style="color:#204a87;font-weight:bold">void</span> <span style="color:#000">initByType</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#204a87;font-weight:bold">int</span> <span style="color:#000">type</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
        <span style="color:#000">List</span><span style="color:#ce5c00;font-weight:bold">&lt;</span><span style="color:#000">InstanceInfo</span><span style="color:#ce5c00;font-weight:bold">&gt;</span> <span style="color:#000">instanceInfoList</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceDao</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getInstListByType</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">type</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#204a87;font-weight:bold">for</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">InstanceInfo</span> <span style="color:#000">instanceInfo</span> <span style="color:#ce5c00;font-weight:bold">:</span> <span style="color:#000">instanceInfoList</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
            <span style="color:#204a87;font-weight:bold">if</span> <span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">TypeUtil</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">isRedisSentinel</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getType</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">)</span> <span style="color:#ce5c00;font-weight:bold">{</span>
                <span style="color:#204a87;font-weight:bold">continue</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#ce5c00;font-weight:bold">}</span>
            <span style="color:#000">String</span> <span style="color:#000">host</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getIp</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#204a87;font-weight:bold">int</span> <span style="color:#000">port</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getPort</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#000">Long</span> <span style="color:#000">appId</span> <span style="color:#ce5c00;font-weight:bold">=</span> <span style="color:#000">instanceInfo</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">getAppId</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#000">redisCenter</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">deployRedisCollection</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
            <span style="color:#8f5902;font-style:italic">//将以下句注掉，可以去掉慢日志的job
</span><span style="color:#8f5902;font-style:italic"></span>            <span style="color:#000">redisCenter</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">deployRedisSlowLogCollection</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#000">appId</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">host</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">port</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
        <span style="color:#ce5c00;font-weight:bold">}</span>
        <span style="color:#000">logger</span><span style="color:#ce5c00;font-weight:bold">.</span><span style="color:#c4a000">info</span><span style="color:#ce5c00;font-weight:bold">(</span><span style="color:#4e9a06">&#34;init redis type={} deploy instance done.&#34;</span><span style="color:#ce5c00;font-weight:bold">,</span> <span style="color:#000">type</span><span style="color:#ce5c00;font-weight:bold">)</span><span style="color:#ce5c00;font-weight:bold">;</span>
    <span style="color:#ce5c00;font-weight:bold">}</span></code></pre></div>
    </div>
    <footer class="post-footer">
     

     <div class="post-nav">
    <div class="post-nav-next post-nav-item">
    
        <a href="http://www.shutdown.cn/post/cachecloud%E5%AE%89%E8%A3%85%E9%83%A8%E7%BD%B2%E4%B8%8E%E7%BE%A4%E9%9B%86%E5%88%9B%E5%BB%BA%E6%B5%81%E7%A8%8B%E6%B5%8B%E8%AF%95/" rel="next" title="">
        <i class="fa fa-chevron-left"></i> 
        </a>
    
    </div>

    <div class="post-nav-prev post-nav-item">
    
        <a href="http://www.shutdown.cn/post/centos-shasum-command-not-found/" rel="prev" title="">
         <i class="fa fa-chevron-right"></i>
        </a>
    
    </div>
</div>
      
     
     
     






    </footer>
  </article>
</section>

          </div>
        </div>
        <div class="sidebar-toggle">
  <div class="sidebar-toggle-line-wrap">
    <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
    <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
    <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
  </div>
</div>
<aside id="sidebar" class="sidebar">
  <div class="sidebar-inner">

    <section class="site-overview sidebar-panel  sidebar-panel-active ">
      <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
        src="http://www.shutdown.cn/img/author.jpg"
        alt="不与天斗Domino" />
    <p class="site-author-name" itemprop="name">不与天斗Domino</p>
    <p class="site-description motion-element" itemprop="description"> 
        Programmer &amp; Architect</p>
</div>
      <nav class="site-state motion-element">
    <div class="site-state-item site-state-posts">
      <a href="http://www.shutdown.cn/post/">
        <span class="site-state-item-count">173</span>
        <span class="site-state-item-name">日志</span>
      </a>
    </div>
    <div class="site-state-item site-state-categories">    
        <a href="http://www.shutdown.cn/categories/">      
         
        <span class="site-state-item-count">10</span>
        
        <span class="site-state-item-name">分类</span>
        
        </a>
    </div>

    <div class="site-state-item site-state-tags">
        <a href="http://www.shutdown.cn/tags/">
         
        <span class="site-state-item-count">63</span>
        
        <span class="site-state-item-name">标签</span>
        </a>
    </div>
</nav>
      
      

      

      <div class="links-of-blogroll motion-element inline">
<script type="text/javascript" src="//rf.revolvermaps.com/0/0/8.js?i=&amp;m=0&amp;s=220&amp;c=ff0000&amp;cr1=ffffff&amp;f=arial&amp;l=33&amp;bv=35" async="async"></script>
</div>

    </section>
    
  </div>
</aside>

      </div>
    </main>
   
    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  <span itemprop="copyrightYear">  &copy; 
  2013 - 2022</span>
  <span class="with-love"><i class="fa fa-heart"></i></span>
  <span class="author" itemprop="copyrightHolder">天地维杰网</span>
  <span class="icp" itemprop="copyrightHolder"><a href="https://beian.miit.gov.cn/" target="_blank">京ICP备13019191号-1</a></span>
</div>
<div class="powered-by">
  Powered by - <a class="theme-link" href="http://gohugo.io" target="_blank" title="hugo" >Hugo v0.63.2</a>
</div>
<div class="theme-info">
  Theme by - <a class="theme-link" href="https://github.com/xtfly/hugo-theme-next" target="_blank"> NexT
  </a>
</div>


      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
      <span id="scrollpercent"><span>0</span>%</span>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/jquery/index.js?v=2.1.3"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/fastclick/lib/fastclick.min.js?v=1.0.6"></script> 
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/velocity/velocity.min.js?v=1.2.1"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/vendor/velocity/velocity.ui.min.js?v=1.2.1"></script>
<script src="http://www.shutdown.cn/js/vendor/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>

<script src="http://www.shutdown.cn/js/vendor/fancybox/jquery.fancybox.pack.js?v=2.1.5"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/utils.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/motion.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/affix.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/schemes/pisces.js"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/scrollspy.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/post-details.js"></script>
<script type="text/javascript" src="http://www.shutdown.cn/js/toc.js"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/bootstrap.js"></script>

<script type="text/javascript" src="http://www.shutdown.cn/js/search.js"></script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX", "output/HTML-CSS"],
    tex2jax: {
      inlineMath: [ ['$','$'] ],
      displayMath: [ ['$$','$$'] ],
      processEscapes: true
    },
    "HTML-CSS": { fonts: ["TeX"] }
  });
</script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML' async></script>
</body>
</html>